//
//  mm_addRepairItemToIndicationListUserDefinedCell.m
//  HondaPro_2
//
//  Created by Eric on 13-7-15.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "mm_addRepairItemToIndicationListUserDefinedCell.h"

@implementation mm_addRepairItemToIndicationListUserDefinedCell
@synthesize arrAllKeysOnCell = _arrAllKeysOnCell;
@synthesize dicAllLblsOnCell = _dicAllLblsOnCell;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        [self initLblsOnCell];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)initLblsOnCell
{
    // @"CLAIM_LABOUR",
    self.arrAllKeysOnCell = [NSArray arrayWithObjects:
                       @"LABOUR_CODE",
                       @"LABOUR_NAME",
                       @"STD_LABOUR_HOUR",
                       nil];
    
    NSDictionary *dicAllLblsRect = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSValue valueWithCGRect:CGRectMake(0, 0, 223, 50)],@"LABOUR_CODE",
                                    [NSValue valueWithCGRect:CGRectMake(224, 0, 329, 50)],@"LABOUR_NAME",
                                    [NSValue valueWithCGRect:CGRectMake(716, 0, 163, 50)],@"STD_LABOUR_HOUR",
                                    [NSValue valueWithCGRect:CGRectMake(879, 0, 162, 50)],@"CLAIM_LABOUR", nil];
    
    self.dicAllLblsOnCell = [NSMutableDictionary dictionaryWithCapacity:[_arrAllKeysOnCell count]];
    
    for (int i = 0; i<[_arrAllKeysOnCell count]; i++)
    {
        NSString *strKey = [_arrAllKeysOnCell objectAtIndex:i];
        CGRect rect = (CGRect)[[dicAllLblsRect objectForKey:strKey] CGRectValue];
        UILabel *lbl = [[UILabel alloc] initWithFrame:rect];
        lbl.textAlignment=NSTextAlignmentCenter;
        lbl.backgroundColor = [UIColor clearColor];
        lbl.font = [UIFont systemFontOfSize:16];
        lbl.textColor = [UIColor grayColor];
        [self.dicAllLblsOnCell setObject:lbl forKey:strKey];
        [self.contentView addSubview:lbl];
    }
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat w=self.bounds.size.width/[_arrAllKeysOnCell count];
    int i =0;
    for (UILabel*label in self.contentView.subviews) {
        label.frame=CGRectMake(i*w, 0, w, self.bounds.size.height);
        i++;
    }
}
@end
